package Servlet;//导入必须的包
import java.io.*;

import javax.servlet.http.*;

//拓展继承HttpServlet类
public class AServlet extends HttpServlet {

	public AServlet(){
		super();
	}

	// 处理doGet方法
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws  IOException {

		// 设置响应内容类型
		response.setContentType("text/html");

		//利用创建PrintWriter对象，将内容输出到页面上
		PrintWriter out = response.getWriter();

		String title = "Using GET Method to Read Form Data";
		String docType = "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">";
		out.println(docType +
				"<html>" +
				"<head>" +
				"<title>" + title+ "</title>" +
				"</head>" +
				"<body>"+
				"<h1 align=\"center\">" + title + "</h1>" + "<ul>"+
				"<li><b>username</b>:" + request.getParameter("username")+
				"<li><b>password</b>:" + request.getParameter("password")+"</ul>" +
				"</body>" +
				"</html>");
	}

	//doPost方法
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws  IOException {
		doGet(request, response);
	}
}